﻿namespace h122
{
    public class Solution {
        public int FindMin(int[] nums) {
            int step = 0;
            int start = 0;
            if( nums[0] <= nums[ nums.Length-1] )
                return nums[0];//旋转点就是0，相当于没转
            while(true)
            {
                if( nums[start]>nums[start+1])
                    break;
                int index =  start + ( 1 << step ); 
                if( index >= nums.Length ||  nums[index] < nums[0] )
                {
                    if( step > 0 )
                        step--;
                    start = start + ( 1 << step ); 
                    step = 0;
                }
                else
                {
                    step++;
                }
            }
            return nums[start+1];
        }
    }
    
}